<?php
namespace Api\Controller;
use Think\Controller,
    Api\Model\TongbuModel;

class TongbuController extends Controller
{
    public $users = array('panda');
    public $m_tongbu;

    public function _initialize()
    {
        $this->m_tongbu = new TongbuModel();
    }

    public function index()
    {
        exit;
    }

    //同步一个商品，这个商品的信息是从 oa 中 post 过来的
    public function add_one_goods()
    {
        $post = I('post.', '', 'trim');
        if( ! in_array($post['auth'], $this->users)){ exit('no'); }
        $rs = $this->m_tongbu->tongbuOneGoods($post);
        $this->ajaxReturn($rs);
        exit;
    }

    //同步一批 goods_links
    public function add_goods_links()
    {
        $post = I('post.', '', 'trim');
        if( ! in_array($post['auth'], $this->users)){ exit('no'); }
        $rs = $this->m_tongbu->tongbuGoodsLinks($post);
        $this->ajaxReturn($rs);
        exit;
    }

    //得到一个订单
    public function get_order()
    {
        $act = $_GET['act'];
        if($act == "tongbu"){
            $rs = $this->m_tongbu->getOrderBySn(I('get.order_sn'));
        }else{
            $rs = array('st'=>'err', 'msg'=>'认证错误');
        }
        $this->ajaxReturn($rs);
        exit;
    }

    //空方法
    public function _empty()
    {
        $a_lost = new \Home\Controller\LostController();
        $a_lost->index();
        return;
    }
}